/**
 * 跳转到我的页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goMy = () => {
    return go("/mine/index")
}

/**
 * 跳转到我的页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goNewsList = () => {
    return go("/index/NewsList")
}


export const goMyFamily = () => {
    return go("/mine/MyFamily")
}

/**
 * 跳转到登录页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goLogin = () => {
    return go("/login/index")
}

/**
 * 跳转到注册页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goRegister = () => {
    return go("/register/index")
}

/**
 * 跳转到首页
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goHome = () => {
    return go("/index/index")
}

/**
 * 跳转到社区页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goCommunity = () => {
    return go("/community/index")
}

/**
 * 跳转到亲属拜访页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goRelativeVisit = () => {
    return go("/community/RelativeVisit")
}

/**
 * 跳转到服务页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goService = () => {
    return go("/service/index")
}

/**
 * 跳转到邻里页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goNeighborhood = () => {
    return go("/neighborhood/index")
}

/**
 * 跳转到我的帖子页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goPostDetail = (id) => {
    return go("/neighborhood/postDetail?id=" + id)
}

/**
 * 跳转到特价拼车页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goCarpooling = (id) => {
    return go("/community/Carpooling")
}

/**
 * 跳转到信息页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goInfo = () => {
    return go("/register/info")
}

/**
 * 跳转到户籍管理
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goHousehol = () => {
    return go("/mine/Househol")
}

/**
 * 跳转到添加租户成员页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goHouseinfo = () => {
    return go("/mine/Houseinfo")
}
export const goEditHouseinfo = (id) => {
    return go("/mine/Houseinfo?id=" + id)
}
/**
 * 跳转到团购页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goGroupBuying = () => {
    return go("/service/GroupBuying")
}

/**
 * 跳转到党建页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goPartyBuilding = () => {
    return go("/service/PartyBuilding")
}

/**
 * 跳转到就业页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goemployment = () => {
    return go("/service/employment")
}

/**
 * 跳转到垃圾分类页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goWaste = () => {
    return go("/index/Waste")
}

/**
 * 跳转到垃圾分类详情页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goWastedetail = (id) => {
    return go("/index/Wastedetail?id=" + id )
}

/**
 * 跳转到招聘页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const gohire = () => {
    return go("/community/hire")
}

/**
 * 跳转到租售页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goRentandsell = () => {
    return go("/community/Rentandsell")
}

/**
 * 跳转到家政服务页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const gohousekeeping = () => {
    return go("/service/housekeeping")
}

/**
 * 跳转到管理页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const gomanage = () => {
    return go("/service/manage")
}


/**
 * 跳转到管理页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goPropertdetails = () => {
    return go("/mine/Propertydetails")
}


/**
 * 跳转到添加成员页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goAddmembers = () => {
    return go("/service/Addmembers")
}

/**
 * 跳转到社区活动页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goNeigh = () => {
    return go("/service/Neighborhood")
}

/**
 * 跳转到养老页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const gopension = () => {
    return go("/service/pension")
}

/**
 * 跳转到投票页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const govote = () => {
    return go("/service/vote")
}

/**
 * 跳转到选举排名页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goelectionRankings = () => {
    return go("/service/electionRankings")
}

/**
 * 跳转到教育页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goEducate = () => {
    return go("/service/goEducate")
}

/**
 * 跳转到访客邀请页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goGuestInvitation = () => {
    return go("/community/GuestInvitation")
}

/**
 * 跳转到帖子编辑页面
 *
 */
export const goPostEdit = () => {
    return go("/neighborhood/postEdit")
}

/**
 * 跳转到帖子编辑页面
 *
 */
export const goPostEditById = (id) => {
    return go("/neighborhood/postEdit?id=" + id)
}

/**
 * 返回上一页
 */
export const goBack = () => {
    uni.navigateBack({
        delta: 1
    })
}

/**
 * 路由跳转前的钩子函数
 * @param {string} data 路由路径
 */
const goBef = (data) => {
    // console.log(data)
}

/**
 * 路由跳转后的钩子函数
 * @param {Object} data 路由跳转结果
 */
const goAft = (data) => {
    // console.log(data)
}

export const getRouteParams = (name) => {
    let Pa = new RegExp(`${name}=([^&]+)`)
    if (Pa.exec(location.href) == null) return null
    return Pa.exec(location.href)[1]
}

/**
 * 通用路由跳转函数
 * @param {string} path 目标路径
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const go = (path) => {
    return new Promise(resolve => {
        goBef(path)
        uni.navigateTo({
            url: ".." + path
        }).then(res => {
            goAft(res)
        })
        resolve()
    })
}

/**
 * 跳转到社区公告页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goCommunityAnnouncement = () => {
    return go("/service/Community")
}

/**
 * 跳转到智慧停车页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goSmartParking = () => {
    return go("/service/SmartParking")
}

/**
 * 跳转到物业报修页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goPropertyRepair = () => {
    return go("/Report/index")
}

/**
 * 跳转到呼叫电梯页面
 * @return {Promise<unknown>} 路由跳转的Promise
 */
export const goCallElevator = () => {
    return go("/community/CallElevator")
}

// 新增的跳转功能
export const gocomplaints = () => {
    return go("/service/complaints")
}

export const goCommunityActivities = () => {
    return go("/service/CommunityActivities")
}

export const goCommunityMutualHelp = () => {
    return go("/service/CommunityMutualHelp")
}

export const goIdleServices = () => {
    return go("/service/IdleServices")
}

export const goPayment = () => {
    return go("/community/Payment")
}

export const gohouse = () => {
    return go("/mine/house")
}

export const goManage = () => {
    return go("/manage/index")
}

export const goHouseholdManagement = () => {
    return go("/mine/HouseholdManagement")
}

export const goEditHouse = () => {
    return go("/mine/editHouse")
}

export const goRecycleOrderList = () => {
    return go("/mine/RecycleOrderList")
}
//公告管理页面
export const goAnctManagement = () => {
    return go("/manage/AnctManagement")
}
// go.js 文件

export const goNews = (id) => {
    return go("/index/news?id=" + id)
}
//帖子审核
export const goPostReview = (id) => {
    return go("/manage/PostReview")
}
//公告新增
export const goNewAnnouncement = () => {
    return go("/manage/NewAnnouncement")
}

//公告编辑
export const goEditNewAnnouncement = (id) => {
    return go("/manage/NewAnnouncement?id=" + id)
}
//用户管理编辑
export const goUserManagementEditing = (id) => {
    return go("/manage/UserManagementEditing?id=" + id)
}
//用户管理编辑
export const goRoleDe = () => {
    return go("/manage/RoleDetail")
}
//用户管理编辑
export const goAnnouncementDetails = (id) => {
    return go("/community/AnnouncementDetails?id=" + id)
}

export const goAiManage = () => {
    return go("/manage/AiManage")
}